package com.szh.zx.duoxiancheng.chapter1;

/**
 * 多个对象操作一个对象
 */
public class TestThread4 implements Runnable {
	//
	private int ticketNUm = 10;

	@Override
	public void run() {
		while (true) {
			if (ticketNUm <= 0) {
				break;


			}
			try {
				Thread.sleep(1000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			System.out.println(Thread.currentThread().getName() + "---->拿到了第：" + ticketNUm--);
		}

	}

	public static void main(String[] args) {
		TestThread4 testThread4 = new TestThread4();
		new Thread(testThread4, "小米").start();
		new Thread(testThread4, "ddd").start();
		new Thread(testThread4, "老师").start();
	}
}
